<template>
  <div class="">
    <div class="ly_list_box">
      <div class="ly_list"
           v-for="item in lists"
           :key="item.pet_id"
           @click="xqclick(item.pet_id)">
        <div class="ly_img">
          <img :src="item.image"
               alt="">
          <div class="ly_name">
            <span>{{ item.age }}</span>
          </div>
        </div>
        <div class="name">
          <span>{{ item.petname  }}</span>
        </div>
        <!-- 宠物详情卡片 -->
        <el-dialog :model-value="xiangqing === item.pet_id"
                   :close-on-click-modal="false"
                   width="1000"
                   :before-close="handleClose">
          <div class="jianjie">
            <!-- <div class="title">
            {{ cwname }}
          </div> -->
            <img :src="item.image"
                 alt="">
            <div class="xinxi">
              <p>宠物名字：{{ item.petname }}</p>
              <p>添加时间：{{ item.publish_time}}</p>
              <p class="liangge">
                <span>性别：{{ item.gender }}</span>
                <span>是否打疫苗：{{ item.health }}</span>
              </p>
              <p class="liangge">
                <span>年龄：{{ item.age }}</span>
                <span>是否绝育：{{ item.sterilization }}&nbsp;&nbsp;&nbsp;</span>
              </p>
              <p>发现区域：{{ item.region }}</p>
              <p>描述：{{ item.briefing }}</p>
              <p class="lyanniu"
                 @click="wylyang(item.pet_id)">我要领养</p>
            </div>
          </div>
        </el-dialog>
      </div>

    </div>
  </div>
</template>



<script>
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
export default {
  props: {
    lists: {
      type: Array
    }
  },
  components: {},
  setup() {
    const router = useRouter()
    //领养信息卡片
    let xiangqing = ref(null)
    let xqclick = (id) => {
      // xiangqing.value = null
      xiangqing.value = id
    }
    let wylyang = (item) => {
      // console.log(item)
      localStorage.setItem('cwxx', item)
      router.push('/lyxinxi')
    }
    let handleClose = (done) => {
      done()
      setTimeout(() => {
        xiangqing.value = null
      }, 10)
    }
    onMounted(() => {})

    return {
      xiangqing,
      xqclick,
      wylyang,
      handleClose
    }
  }
}
</script>

<style scoped lang="less">
.ly_list_box {
  width: 1000px;
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;

  .ly_list {
    margin: 0 15px;
    width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    .ly_img {
      position: relative;
      overflow: hidden;
      width: 300px;
      height: 223px;
      border-radius: 10% 25%;
      border-bottom: #cdbf62 8px solid;
      border-left: #cdbf62 8px solid;
      border-right: #cdbf62 8px dashed;
      border-top: #cdbf62 8px dashed;
      img {
        width: 100%;
        height: 100%;
      }
      .ly_name {
        width: 100%;
        height: 80px;
        line-height: 80px;
        text-align: center;
        margin-top: 10px;
        position: absolute;
        bottom: -80px;
        left: 0;
        background-color: rgba(0, 0, 0, 0.4);
        transition: all 0.5s ease;
        span {
          font-size: 20px;
          font-weight: 700;
          color: #cdbf62;
        }
      }
    }
    .ly_img:hover {
      .ly_name {
        transform: translate(0, -80px);
      }
    }
    .name {
      margin-top: 10px;
      width: 60%;
      height: 40px;
      line-height: 40px;
      text-align: center;
      background-color: #eeecde;
      border-bottom: #cdbf62 3px solid;
      border-top: #cdbf62 1px dashed;
      border-left: #cdbf62 1px solid;
      border-right: #cdbf62 1px solid;
      border-radius: 15px;
      span {
        font-size: 20px;
        font-weight: 700;
        color: #cdbf62;
      }
    }
  }
  .jianjie {
    width: 100%;
    height: 665px;
    background-color: #eeecde;
    display: flex;
    flex-direction: column;
    align-items: center;
    .title {
      margin-top: 10px;
      width: 60%;
      height: 40px;
      line-height: 40px;
      text-align: center;
      background-color: #eeecde;
      border-bottom: #cdbf62 3px solid;
      border-top: #cdbf62 1px dashed;
      border-left: #cdbf62 1px solid;
      border-right: #cdbf62 1px solid;
      border-radius: 15px;
      font-size: 20px;
      font-weight: 700;
      color: #cdbf62;
    }
    img {
      width: 760px;
      height: 475px;
    }
    .xinxi {
      font-size: 16px;
      p {
        width: 800px;
        // white-space: nowrap; /* 防止文本换行 */
        // overflow: hidden; /* 隐藏溢出内容 */
        // text-overflow: ellipsis;
      }
      .liangge {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 60%;
        span {
          display: inline-block;
          width: 128px;
        }
      }
      .lyanniu {
        margin: 10px 0 0 165px;
        width: 60%;
        height: 40px;
        line-height: 40px;
        text-align: center;
        background-color: #fff;
        border-bottom: #cdbf62 3px solid;
        border-top: #cdbf62 1px dashed;
        border-left: #cdbf62 1px solid;
        border-right: #cdbf62 1px solid;
        border-radius: 15px;
        font-size: 20px;
        font-weight: 700;
        color: #e18ba2;
        cursor: pointer;
      }
    }
  }
}
</style>

